package nil.ed.simulator.request.biz.qq.listener;

import nil.ed.simulator.request.biz.qq.scheduler.QqLoginScheduleUnit;
import nil.ed.simulator.request.enums.events.EventType;
import nil.ed.simulator.request.event.Event;
import nil.ed.simulator.request.event.bus.EventListener;
import nil.ed.simulator.request.repo.RuntimeRepo;

/**
 * @author lidelin.
 */
public class QqItemScheduleUnitFinishListener implements EventListener {
    @Override
    public void onEvent(Event event) {
        QqLoginScheduleUnit scheduleUnit = (QqLoginScheduleUnit) event.getData();
        synchronized (RuntimeRepo.QQ_REPO.LOCK) {
            RuntimeRepo.QQ_REPO.getFinished().add(scheduleUnit);
        }
    }

    @Override
    public boolean isSupport(Event event) {
        return event.getData() instanceof QqLoginScheduleUnit && event.getEventType() == EventType.SCHEDULER_FINISH;
    }
}
